package main_test

import (
	"net/http"

	"github.com/cjoudrey/gluahttp"
	lua "github.com/yuin/gopher-lua"
)

func Main8() {
	L := lua.NewState()
	defer L.Close()

	L.PreloadModule("http", gluahttp.NewHttpModule(&http.Client{}).Loader)

	if err := L.DoString(`

        local http = require("http")

        response, error_message = http.request("GET", "http://www.baidu.com", {
            query="page=1",
            timeout="30s",
            headers={
                Accept="*/*"
            }
        })

        print(response.body)

    `); err != nil {
		panic(err)
	}
}
